package com.donn.securitycontrolplatform.hisalarm.controller;


import com.dahuatech.icc.exception.ClientException;
import com.donn.securitycontrolplatform.common.Result;
import com.donn.securitycontrolplatform.common.entity.dahua.PageDTO;
import com.donn.securitycontrolplatform.hisalarm.entity.THisAlarm;
import com.donn.securitycontrolplatform.hisalarm.service.ITHisAlarmService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhenglx
 * @since 2022-06-26
 */
@RestController
@Slf4j
@RequestMapping("/scp/api/his-alarm")
@Tag(name = "HisAlarmController", description = "历史告警")
public class HisAlarmController {

    @Autowired
    ITHisAlarmService service;

    @ApiOperation(value = "修改告警状态")
    @GetMapping("/update")
    @ResponseBody
    public Result update(@RequestParam String hisAlarmId) {
        return service.updateHisAlarm(hisAlarmId);
    }

    @ApiOperation(value = "删除告警")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "hisAlarmId", value = "告警id")
    })
    @DeleteMapping("/delete")
    @ResponseBody
    public Result delete(@RequestParam String hisAlarmId) {
        return service.deleteHisAlarm(hisAlarmId);
    }

    @ApiOperation(value = "分页查询列表")
    @PostMapping("/page")
    @ResponseBody
    public Result page(@RequestBody PageDTO<THisAlarm> page) {
        log.info("page=" + page.getSort() + " sorttype=" + page.getSortType());
        return service.getPage(page.page());
    }

    @ApiOperation(value = "获取抓拍图片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "hisAlarmId", value = "告警id")
    })
    @GetMapping("/getImg")
    @ResponseBody
    public Result getImg(@RequestParam String imgUri) throws ClientException {
        return service.getImg(imgUri);
    }


    @ApiOperation(value = "获取今年报警数量 每月一个数字")
    @GetMapping("/getMonthData")
    @ResponseBody
    public Result getYearData() throws ClientException {

        return service.getYearData();
    }


    @ApiOperation(value = "获取今年入侵与违规人员报警数量 每月一个数字")
    @GetMapping("/getYearDataByViolation")
    @ResponseBody
    public Result getYearDataByViolation() throws ClientException {

        return service.getYearDataByViolation();
    }


    @ApiOperation(value = "获取最近11天的告警数据")
    @GetMapping("/getDayData")
    @ResponseBody
    public Result getDayData() throws ClientException {

        return service.getDayData();
    }

}
